summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorboludoz <francomaro@gmail.com>2023-10-15 19:44:23 +0200
committerboludoz <francomaro@gmail.com>2023-10-15 19:44:23 +0200
commit4d4fe69223bd6cd053cbd2088e5925fb653a12d3 (patch)
tree5559faeafc73e93fc652588e6556e6bb97fb4d6b
parentFixes and improvements (diff)
downloadyuzu-4d4fe69223bd6cd053cbd2088e5925fb653a12d3.tar
yuzu-4d4fe69223bd6cd053cbd2088e5925fb653a12d3.tar.gz
yuzu-4d4fe69223bd6cd053cbd2088e5925fb653a12d3.tar.bz2
yuzu-4d4fe69223bd6cd053cbd2088e5925fb653a12d3.tar.lz
yuzu-4d4fe69223bd6cd053cbd2088e5925fb653a12d3.tar.xz
yuzu-4d4fe69223bd6cd053cbd2088e5925fb653a12d3.tar.zst
yuzu-4d4fe69223bd6cd053cbd2088e5925fb653a12d3.zip
-rw-r--r--src/common/fs/path_util.cpp70
-rw-r--r--src/common/fs/path_util.h15
-rw-r--r--src/yuzu/main.cpp16
-rw-r--r--src/yuzu/util/util.h3
4 files changed, 5 insertions, 99 deletions
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index f030939ce..bccf953e4 100644
--- a/src/common/fs/path_util.cpp
+++ b/src/common/fs/path_util.cpp
@@ -348,76 +348,6 @@ fs::path GetBundleDirectory() {
#endif
-fs::path GetDesktopPath() {
-#if defined(_WIN32)
- PWSTR DesktopPath = nullptr;
-
- if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &DesktopPath))) {
- std::wstring wideDesktopPath(DesktopPath);
- CoTaskMemFree(DesktopPath);
-
- // UTF-16 filesystem lib to UTF-8 is broken, so we need to convert to UTF-8 with the with
- // the Windows library (Filesystem converts the strings literally).
- return fs::path{Common::UTF16ToUTF8(wideDesktopPath)};
- } else {
- LOG_ERROR(Common_Filesystem,
- "[GetDesktopPath] Failed to get the path to the desktop directory");
- }
- return fs::path{};
-#else
- fs::path shortcut_path{};
-
- // Array of possible desktop
- std::vector<std::string> desktop_paths = {
- "Desktop", "Escritorio", "Bureau", "Skrivebord", "Plocha",
- "Skrivbord", "Desktop", "Рабочий стол", "Pulpit", "Área de Trabalho",
- "Робочий стіл", "Bureaublad", "デスクトップ", "桌面", "Pöytä",
- "바탕 화면", "바탕 화면", "سطح المكتب", "دسکتاپ", "שולחן עבודה"};
-
- for (auto& path : desktop_paths) {
- if (fs::exists(GetHomeDirectory() / path)) {
- return path;
- }
- }
-
- LOG_ERROR(Common_Filesystem,
- "[GetDesktopPath] Failed to get the path to the desktop directory");
-
- return shortcut_path;
-#endif
-}
-
-fs::path GetAppsShortcutsPath() {
-#if defined(_WIN32)
- PWSTR AppShortcutsPath = nullptr;
-
- if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_CommonPrograms, 0, NULL, &AppShortcutsPath))) {
- std::wstring wideAppShortcutsPath(AppShortcutsPath);
- CoTaskMemFree(AppShortcutsPath);
-
- // UTF-16 filesystem lib to UTF-8 is broken, so we need to convert to UTF-8 with the with
- // the Windows library (Filesystem converts the strings literally).
- return fs::path{Common::UTF16ToUTF8(wideAppShortcutsPath)};
- } else {
- LOG_ERROR(Common_Filesystem,
- "[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts directory");
- }
-
- return fs::path{};
-#else
- fs::path shortcut_path = GetHomeDirectory() / ".local/share/applications";
- if (!fs::exists(shortcut_path)) {
- shortcut_path = std::filesystem::path("/usr/share/applications");
- if (!fs::exists(shortcut_path)) {
- LOG_ERROR(Common_Filesystem,
- "[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts "
- "directory");
- }
- }
- return fs::path{};
-#endif
-}
-
// vvvvvvvvvv Deprecated vvvvvvvvvv //
std::string_view RemoveTrailingSlash(std::string_view path) {
diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h
index b88a388d1..63801c924 100644
--- a/src/common/fs/path_util.h
+++ b/src/common/fs/path_util.h
@@ -244,6 +244,7 @@ void SetYuzuPath(YuzuPath yuzu_path, const Path& new_path) {
* @returns The path of the current user's %APPDATA% directory.
*/
[[nodiscard]] std::filesystem::path GetAppDataRoamingDirectory();
+
#else
/**
@@ -274,20 +275,6 @@ void SetYuzuPath(YuzuPath yuzu_path, const Path& new_path) {
#endif
-/**
- * Gets the path of the current user's desktop directory.
- *
- * @returns The path of the current user's desktop directory.
- */
-[[nodiscard]] std::filesystem::path GetDesktopPath();
-
-/**
- * Gets the path of the current user's apps directory.
- *
- * @returns The path of the current user's apps directory.
- */
-[[nodiscard]] std::filesystem::path GetAppsShortcutsPath();
-
// vvvvvvvvvv Deprecated vvvvvvvvvv //
// Removes the final '/' or '\' if one exists
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index e4dc717ed..fd68ac9b6 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -3082,13 +3082,9 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
// Shortcut path
std::filesystem::path shortcut_path{};
if (target == GameListShortcutTarget::Desktop) {
- shortcut_path = Common::FS::GetDesktopPath();
- if (!std::filesystem::exists(shortcut_path)) {
- shortcut_path =
- QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString();
- }
+ shortcut_path =
+ QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString();
} else if (target == GameListShortcutTarget::Applications) {
-
#if defined(_WIN32)
HANDLE hProcess = GetCurrentProcess();
if (!IsUserAnAdmin()) {
@@ -3098,12 +3094,8 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
}
CloseHandle(hProcess);
#endif // _WIN32
-
- shortcut_path = Common::FS::GetAppsShortcutsPath();
- if (!std::filesystem::exists(shortcut_path)) {
- shortcut_path = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)
- .toStdString();
- }
+ shortcut_path =
+ QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString();
}
// Icon path and title
diff --git a/src/yuzu/util/util.h b/src/yuzu/util/util.h
index 8839e160a..31e82ff67 100644
--- a/src/yuzu/util/util.h
+++ b/src/yuzu/util/util.h
@@ -8,11 +8,9 @@
#include <QString>
/// Returns a QFont object appropriate to use as a monospace font for debugging widgets, etc.
-
[[nodiscard]] QFont GetMonospaceFont();
/// Convert a size in bytes into a readable format (KiB, MiB, etc.)
-
[[nodiscard]] QString ReadableByteSize(qulonglong size);
/**
@@ -34,5 +32,4 @@
*
* @return bool If the operation succeeded
*/
-
[[nodiscard]] bool SaveIconToFile(const QImage& image, const std::filesystem::path& icon_path);